
export function getHeroKnowledgeGraphOption(data) {
  const option = {
    title: {
      text: '英雄联盟角色知识图谱'
    },
    tooltip: {},
    legend: {
      right: "10%",
      show: true,
      orient: "vertical",
      data: data.categories.map(function (a) {
          return a.name;
        })

    },
    animationDurationUpdate: 1500,
    animationEasingUpdate: 'quinticInOut',
    series: [
      {
        type: 'graph',
        layout: 'force',
        symbolSize: 70,
        edgeSymbol: ['circle', 'arrow'],
        edgeSymbolSize: [4, 4],
        edgeLabel: {
          show: true,
          fontSize: 14,
          formatter: "{c}"
        },
        force: {
            repulsion: 2500,
            edgeLength: [15, 100]
        },
        focus: 'adjacency',
        draggable: true,
        roam: true,
        label: {
          show: true,
          formatter: function(params){
            return params.data.showName
          },
          fontSize: 14
        },
        data: data.nodes,
        links: data.links,
        categories: data.categories,
        lineStyle: {
          opacity: 0.9,
          width: 2,
          curveness: 0
        }
      }
    ]
  };
  return option
}

/**
 *
 * data = [1,2,3,4]
 * data = [攻击,防御,魔法,上手难度]
 */
export function getHeroAttributeChartOption(data) {
  const result = []
  const color = ["rgb(169,0,0)", "rgb(145,204,117)", "rgb(84,112,198)", "rgb(250,200,88)"]
  for(let i = 0; i < 4; i++) {
    const value = data[i]
    const tempObj = {
      value,
      itemStyle: {
        color: color[i]
      }
    }
    result.push(tempObj)
  }
  const option = {
    tooltip: {
      trigger: 'axis',
    },
    xAxis: {
      type: 'category',
      data: ['攻击', '防御', '法术', '上手难度']
    },
    yAxis: {
      type: 'value'
    },
    title: {
      text: '英雄属性',
    },
    series: [
      {
        data: result,
        type: 'bar',
        showBackground: true,
        backgroundStyle: {
          color: 'rgba(180, 180, 180, 0.2)'
        }
      }
    ]
  };
  return option
}
